﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using ProgNetComponents.Data.SqlCe;
using DevExpress.XtraTab;

namespace BuildHelper.Work.Tools
{
    public partial class SecurityFileCheckForm : XtraForm
    {
        private bool isClosing = false;

        public SecurityFileCheckForm()
        {
            InitializeComponent();
        }

        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            isClosing = true;
            base.OnFormClosing(e);
        }
        private BranczSecInfo Brancz1SecInfo;
        private BranczSecInfo Brancz2SecInfo;

        private void btnSprawdz_Click(object sender, EventArgs e)
        {
            if (GetBranczInfo1())
            {
                foreach (XtraTabPage p in tabWyniki1.TabPages.ToArray())
                    p.Dispose();

                tabWyniki1.TabPages.Clear();

                var dic = GetSecInfo(Brancz1SecInfo, null);
                foreach (KeyValuePair<string, List<string>> kvp in dic)
                {
                    AddPage(tabWyniki1, kvp.Key, kvp.Value);
                }
            }
        }
        private void GetBranczSecInfo()
        {
            Brancz1SecInfo = new BranczSecInfo(lueBrancz.EditValue.AsString());
            Brancz1SecInfo.GetInfo();
            while (!Brancz1SecInfo.InfoPrepared)
            {
                if (Program.IsExit || isClosing)
                    break;
                Application.DoEvents();
            }
        }
       
        private void CheckBranczSecInfo(BranczSecInfo info)
        {
            if (info != null)
            {
                foreach (var kvp in info.SecInfosForSystem)
                {
                   
                }
            }
        }
        private bool GetBranczInfo1()
        {
            //if (Brancz1SecInfo != null)
            //    return true;
            if (lueBrancz.EditValue.AsString() != null)
            {
                using (ProgNetComponentsDx.Forms.FormBackGroundWorkSingleThread f = new ProgNetComponentsDx.Forms.FormBackGroundWorkSingleThread("Czytanie danych Brancza " + lueBrancz.EditValue.AsString()))
                {
                    f.DoWork += new DoWorkEventHandler(f_DoWork);
                    Brancz1SecInfo = new BranczSecInfo(lueBrancz.EditValue.AsString());
                    f.ShowDialog();
                }
                return true;
            }
            else
            {
                this.ShowDxInfoDialog("Wybierz brancza 1");
                return false;
            }
        }
        private bool GetBranczInfo2()
        {
            //if (Brancz2SecInfo != null)
           //     return true;
            if (lueBrancz2.EditValue.AsString() != null)
            {
                using (ProgNetComponentsDx.Forms.FormBackGroundWorkSingleThread f2 = new ProgNetComponentsDx.Forms.FormBackGroundWorkSingleThread("Czytanie danych Brancza " + lueBrancz2.EditValue.AsString()))
                {
                    f2.DoWork += new DoWorkEventHandler(f2_DoWork);
                    Brancz2SecInfo = new BranczSecInfo(lueBrancz2.EditValue.AsString());
                    f2.ShowDialog();
                }
                return true;
            }
            else
            {
                this.ShowDxInfoDialog("Wybierz brancza 2");
                return false;
            }
        }
        void f_DoWork(object sender, DoWorkEventArgs e)
        {
            Brancz1SecInfo.GetInfo();
            while (!Brancz1SecInfo.InfoPrepared)
            {
                if (isClosing || Program.IsExit)
                    break;
                System.Threading.Thread.Sleep(50);
            }
        }
        void f2_DoWork(object sender, DoWorkEventArgs e)
        {
            Brancz2SecInfo.GetInfo();
            while (!Brancz2SecInfo.InfoPrepared)
            {
                if (isClosing || Program.IsExit)
                    break;
                System.Threading.Thread.Sleep(50);
            }
        }

        private class BranczInfoStrings
        {
            public static string[] All = new string[]{
                MissingSystem,
                H_Braki,
                SO_Braki,
                SR_Braki,

                P_H_Braki,
                P_GUI_Braki,
                P_SO_Braki,
                P_SR_Braki,

                P_GUI_Diff,
                P_H_Diff,
                P_SO_Diff,
                P_SR_Diff,

                D_Gui,
                D_H,
                D_SecReg,
                D_SecOpt,
                GUI_SEC_Diff
            };

            public const string MissingSystem = "Brakujące systemy";
            public const string H_Braki = "Braki w *.h";
            public const string SO_Braki = "Braki w SecOptions";
            public const string SR_Braki = "Braki w SecRegistration";

            public const string GUI_SEC_Diff = "Różnice w Security i cliencie";

            public const string P_H_Braki = "(Porównanie) Braki w *.h";
            public const string P_GUI_Braki = "(Porównanie) Braki w GUIXXX";
            public const string P_SO_Braki = "(Porównanie) Braki w SecOptions";
            public const string P_SR_Braki = "(Porównanie) Braki w SecRegistration";

            public const string P_H_Diff = "(Porównanie) Różne Kody w *.h";
            public const string P_GUI_Diff = "(Porównanie) Różne Nazwy, Kody w GUIXXX";
            public const string P_SO_Diff = "(Porównanie) Różne Kody w SecOptions";
            public const string P_SR_Diff = "(Porównanie) Różne Parametry w SecRegistration";

            public const string D_Gui = "Duplikaty w GUIXXX";
            public const string D_H = "Duplikaty w *.h";
            public const string D_SecReg = "Duplikaty w SecRegistration";
            public const string D_SecOpt = "Duplikaty w SecOptions";
        }

        private Dictionary<string, List<string>> GetSecInfo(BranczSecInfo s1, BranczSecInfo s2)
        {
            Dictionary<string, List<string>> dic = new Dictionary<string, List<string>>();
            foreach (string str in BranczInfoStrings.All)
                dic.Add(str, new List<string>());

            string system;
            SecInfoClass i2;
            foreach (KeyValuePair<string, SecInfoClass> kvp in s1.SecInfosForSystem)
            {
                system = kvp.Key;
                i2 = null;
                if (s2 != null)
                {
                    if (!s2.SecInfosForSystem.ContainsKey(system))
                        dic[BranczInfoStrings.MissingSystem].Add("Missing system " + system + " in branch " + s2.Brancz);
                    else
                        i2 = s2.SecInfosForSystem[system];
                }
                CheckItems(s1.Brancz, s2 != null ? s2.Brancz : "", kvp.Value, i2, dic);
            }
            return dic;
        }
        private bool IsDuplicated(string value, List<string> values, List<string> duplicates)
        {
            if (values.Contains(value))
            {
                if (!duplicates.Contains(value))
                    duplicates.Add(value);
                return true;
            }
            else
            {
                values.Add(value);
                return false;
            }
        }
        private void CheckItems(string b1, string b2, SecInfoClass s1,SecInfoClass s2, Dictionary<string, List<string>> dic)
        {
            try
            {
                List<string> GuiItemCodes = new List<string>();
                List<string> GuiItemCodesDuplicates = new List<string>();

                List<string> HItemCodes = new List<string>();
                List<string> HItemCodesDuplicates = new List<string>();
                List<string> HItemNumbers = new List<string>();
                List<string> HItemNumbersDuplicates = new List<string>();

                List<string> SOCodes = new List<string>();
                List<string> SOCodesDuplicates = new List<string>();
                List<string> SONumbers = new List<string>();
                List<string> SONumbersDuplicates = new List<string>();

                List<string> SecRegCodes = new List<string>();
                List<string> SecRegCodesDuplicates = new List<string>();
                List<string> SecRegParams = new List<string>();
                List<string> SecRegParamsDuplicates = new List<string>();

                HItem h1, h2;
                GuiItem g2;
                SecOptionItem so1, so2;
                SecRegItem sr1, sr2;
                foreach (GuiItem g1 in s1.GuiItemCollection)
                {
                    g2 = null;
                    h2 = null;
                    h1 = null;
                    so1 = null;
                    so2 = null;
                    sr1 = null;
                    sr2 = null;

                    #region check if number exists in secxxx.h
                    if (!IsDuplicated(g1.Kod, GuiItemCodes, GuiItemCodesDuplicates))
                    {
                        h1 = s1.GetHItemByKod(g1.Kod);
                        if (h1 == null)
                            dic[BranczInfoStrings.H_Braki].Add(s1.System + ": Missing number for GUIXXX option " + g1.Kod + "(" + g1.Nazwa + ") in branch " + b1);
                    }
                    #endregion
                    #region compare secxxx.h and GUIXXX
                    if (s2 != null && h1 != null)
                    {
                        if (!IsDuplicated(h1.Numer, HItemNumbers, HItemNumbersDuplicates))
                        {
                            IsDuplicated(h1.Kod, HItemCodes, HItemCodesDuplicates);

                            h2 = s2.GetHItemByNum(h1.Numer);
                            if (h2 == null)
                                dic[BranczInfoStrings.P_H_Braki].Add(s1.System + ": Missing number " + h1.Numer + " for GUIXXX option " + g1.Kod + "(" + g1.Nazwa + ") in branch " + b2);
                            else
                            {
                                if (h2.Kod != h1.Kod)
                                    dic[BranczInfoStrings.P_H_Diff].Add(s1.System + ": Different code for option " + h1.Numer + " " + b1 + "= " + h1.Kod + ", " + b2 + "= " + h2.Kod);
                                g2 = s2.GetGuiItemByKod(h2.Kod);
                                if (g2 == null)
                                    dic[BranczInfoStrings.P_GUI_Braki].Add(s1.System + ": Option not registered in GUIXXX " + h2.Kod + ", number= " + h2.Numer + " in branch " + b2);
                                else if (g1.Nazwa != g2.Nazwa)
                                    dic[BranczInfoStrings.P_GUI_Diff].Add(s1.System + ": Different name for option " + h2.Kod + ", number= " + h2.Numer + " " + b1 + "= " + g1.Nazwa + ", " + b2 + "= " + g2.Nazwa);
                            }
                        }
                    }
                    #endregion

                    #region check if number exists in SecOptions
                    if (h1 != null)
                    {
                        if (!IsDuplicated(h1.Numer, SONumbers, SONumbersDuplicates))
                        {
                            so1 = s1.GetSecOptionByNum(h1.Numer);
                            if (so1 == null)
                                dic[BranczInfoStrings.SO_Braki].Add(s1.System + ": Missing number " + h1.Numer + ", GUIXXX: " + g1.Kod + " (" + g1.Nazwa + ") in branch " + b1);
                            else if (so1.Kod != h1.Kod)
                                dic[BranczInfoStrings.GUI_SEC_Diff].Add(s1.System + ": Different code for number: " + so1.Numer + " *.h= " + h1.Kod + "("+g1.Nazwa+"), SecOptions= " + so1.Kod + "("+so1.Nazwa+") in branch " + b1);
                        }
                    }
                    #endregion
                    #region compare SecOptions
                    if (s2 != null && so1 != null && h2 != null)
                    {
                        so2 = s2.GetSecOptionByNum(h2.Numer);
                        if (so2 == null)
                            dic[BranczInfoStrings.P_SO_Braki].Add(s1.System + ": Missing number " + h2.Numer + ", GUIXXX: " + g2.Kod + " (" + g2.Nazwa + ") in branch " + b2);
                        else if (so1.Kod != so2.Kod)
                            dic[BranczInfoStrings.P_SO_Diff].Add(s1.System + ": Different code for option " + h1.Numer + " " + b1 + "= " + so1.Kod + ", " + b2 + "= " + so2.Kod);
                    }
                    #endregion
                    #region check if option is registered in SecRegistration
                    if (so1 != null)
                    {
                        if (!IsDuplicated(so1.Kod, SOCodes, SOCodesDuplicates))
                        {
                            sr1 = s1.GetSecRegItemByKod(so1.Kod);
                            if (sr1 == null)
                                dic[BranczInfoStrings.SR_Braki].Add(s1.System + ": Missing option " + so1.Kod + ", GUIXXX: " + g1.Kod + " (" + g1.Nazwa + ") in branch " + b1);
                            else
                            {
                                IsDuplicated(sr1.Kod, SecRegCodes, SecRegCodesDuplicates);
                                IsDuplicated(sr1.Params, SecRegParams, SecRegParamsDuplicates);
                            }
                        }
                    }
                    #endregion
                    #region compare SecRegistration
                    if (s2 != null && sr1 != null && so2 != null)
                    {
                        sr2 = s2.GetSecRegItemByKod(so2.Kod);
                        if (sr2 == null)
                        {
                            if (g2 != null)
                                dic[BranczInfoStrings.P_SR_Braki].Add(s1.System + ": Unregistred option " + so2.Kod + ", GUIXXX: " + g2.Kod + " (" + g2.Nazwa + ") in branch " + b2);
                            else
                                dic[BranczInfoStrings.P_SR_Braki].Add(s1.System + ": Unregistred option " + so2.Kod + ", GUIXXX (missing): " + h2.Kod + " in branch " + b2);
                        }
                        else
                        {
                            if (sr1.Params != sr2.Params)
                            {
                                if (sr1.Kod != sr2.Kod)
                                    dic[BranczInfoStrings.P_SR_Diff].Add(s1.System + ": Different registration parameters for option: " + so1.Numer + " " + b1 + " (" + so1.Kod + ")= " + sr1.Params + ", " + b2 + " (" + so2.Kod + ")= " + sr2.Params);
                                else
                                    dic[BranczInfoStrings.P_SR_Diff].Add(s1.System + ": Different registration parameters for option: " + so1.Numer + "  (" + so1.Kod + ") " + b1 + "= " + sr1.Params + ", " + b2 + "= " + sr2.Params);
                            }
                        }
                    }
                    #endregion
                }

                foreach (string c in GuiItemCodesDuplicates)
                    dic[BranczInfoStrings.D_Gui].Add(s1.System + ": Duplicated Code " + c + " in branch " + b1);
                foreach (string c in HItemCodesDuplicates)
                    dic[BranczInfoStrings.D_H].Add(s1.System + ": Duplicated code " + c + " in branch " + b1);
                foreach (string c in HItemNumbersDuplicates)
                    dic[BranczInfoStrings.D_H].Add(s1.System + ": Duplicated number " + c + " in branch " + b1);
                foreach (string c in SecRegCodesDuplicates)
                    dic[BranczInfoStrings.D_SecReg].Add(s1.System + ": Duplicated code " + c + " in branch " + b1);
                foreach (string c in SecRegParamsDuplicates)
                    dic[BranczInfoStrings.D_SecReg].Add(s1.System + ": Duplicated registration parameters " + c + " in branch " + b1);
                foreach (string c in SOCodesDuplicates)
                    dic[BranczInfoStrings.D_SecOpt].Add(s1.System + ": Duplicated code " + c + " in branch " + b1);
                foreach (string c in SONumbersDuplicates)
                    dic[BranczInfoStrings.D_SecOpt].Add(s1.System + ": Duplicated number " + c + " in branch " + b1);
            }
            catch (Exception ex)
            {
                ex.Log();
            }
        }
      

        private void btnPorownaj_Click(object sender, EventArgs e)
        {
            if (GetBranczInfo1() && GetBranczInfo2())
            {
                foreach (XtraTabPage p in tabWyniki.TabPages.ToArray())
                    p.Dispose();

                tabWyniki.TabPages.Clear();

                var dic = GetSecInfo(Brancz1SecInfo, Brancz2SecInfo);
                foreach (KeyValuePair<string, List<string>> kvp in dic)
                {
                    AddPage(tabWyniki, kvp.Key, kvp.Value);
                }
            }
        }
        private void AddPage(XtraTabControl tab, string text, List<string> list)
        {
            if (list.Count > 0)
            {
                XtraTabPage p = new XtraTabPage();
                p.Text = text;
                MemoEdit me = new MemoEdit();
                me.Lines = list.ToArray();
                list.Clear();
                me.Dock = DockStyle.Fill;
                me.Properties.ReadOnly = true;
                p.Controls.Add(me);
                tab.TabPages.Add(p);
            }
        }
        private void lueBrancz_EditValueChanged(object sender, EventArgs e)
        {
            Brancz1SecInfo = null;
        }

        private void lueBrancz2_EditValueChanged(object sender, EventArgs e)
        {
            Brancz2SecInfo = null;
        }
    }
    
   
    public class BranczSecInfo
    {
        public Dictionary<string, SecInfoClass> SecInfosForSystem = new Dictionary<string, SecInfoClass>();
        public string Brancz { get; private set; }
        public BranczSecInfo(string brancz)
        {
            this.Brancz = brancz;
        }
        public bool InfoPrepared
        {
            get { return InfoCount == MaxInfo; }
        }
        private int InfoCount;
        private int MaxInfo;
        public void GetInfo()
        {
            SecInfosForSystem.Clear();
            using (SqlCeDataManager sqlCeDataManager1 = new SqlCeDataManager())
            {
                Setup.Brancze.BranczeDataSet ds = new Setup.Brancze.BranczeDataSet();
                InfoCount = 0;
                sqlCeDataManager1.AutoLogExceptions = true;
                sqlCeDataManager1.FillTable(ds.STP_BRANCZE, "SELECT * FROM STP_BRANCZE WHERE STP_BR_NAZWA = " + Brancz.EscapeSql());
                sqlCeDataManager1.FillTable(ds.STP_BRANCZE_APPS, "SELECT * FROM STP_BRANCZE_APPS WHERE STP_BR_APP_BRANCZ= " + Brancz.EscapeSql());
                MaxInfo = ds.STP_BRANCZE_APPS.Rows.Count;

                if (ds.STP_BRANCZE.Rows.Count == 1)
                {
                    DataRow r = ds.STP_BRANCZE[0];
                    string katalog = r["STP_BR_KATALOG"].AsString().TrimEnd('\\');
                    string gene = katalog + "\\nd_src\\gene";
                    string apps = katalog + "\\nd_src\\gene\\apps";
                    string sys;
                    foreach (DataRow appRow in ds.STP_BRANCZE_APPS.Rows)
                    {
                        sys = appRow["STP_BR_APP_APP"].ToString();
                        SecInfoClass ci = SecInfoClass.CreateSecInfoClass(sys, apps);
                        ci.InfoRetrived += new EventHandler(ci_InfoRetrived);
                        Task.Factory.StartNew(new Action(ci.GetInfo));
                        SecInfosForSystem.Add(sys, ci);
                    }
                }
            }
        }
        void ci_InfoRetrived(object sender, EventArgs e)
        {
            InfoCount++;   
        }
    }

    public class SystemFile
    {
        public string System { get; set; }
    }
    public class SecInfoClass
    {
        public static SecInfoClass CreateSecInfoClass(string system, string apps)
        {
            SecInfoClass ci = new SecInfoClass();
            ci.System = system;
            ci.Hfile = apps + "\\" + system + @"\src\aix\secs\sec" + system + ".h";
            ci.GUIfile = apps + "\\" + system + @"\src\aix\secs\GUI" + system;
            ci.SecOptions = apps + "\\" + system + @"\src\gui\" + system + "Tools\\" + system + "Security\\SecOptions.cs";
            ci.SecRegistration = apps + "\\" + system + @"\src\gui\" + system + "Tools\\" + system + "Security\\SecRegistration.cs";
            return ci;
        }
        public SecRegItem GetSecRegItemByKod(string kod)
        {
            foreach (SecRegItem i in SecRegCollection)
                if (i.Kod == kod)
                    return i;
            return null;
        }
        public GuiItem GetGuiItemByKod(string kod)
        {
            foreach (GuiItem i in GuiItemCollection)
                if (i.Kod == kod)
                    return i;
            return null;
        }
        public HItem GetHItemByNum(string num)
        {
            foreach (HItem item in HItemCollection)
                if (item.Numer == num)
                    return item;
            return null;
        }
        public HItem GetHItemByKod(string kod)
        {
            foreach (HItem item in HItemCollection)
                if (item.Kod == kod)
                    return item;
            return null;
        }
        public SecOptionItem GetSecOptionByKod(string kod)
        {
            foreach (SecOptionItem item in SecOptionCollection)
                if (item.Kod == kod)
                    return item;
            return null;
        }
        public SecOptionItem GetSecOptionByNum(string num)
        {
            foreach (SecOptionItem item in SecOptionCollection)
                if (item.Numer == num)
                    return item;
            return null;
        }
        private SecInfoClass()
        {
           
        }

        public string System
        {
            get;
            set;
        }
        public string Hfile
        {
            get;
            private set;
        }
        public string GUIfile
        {
            get;
            private  set;
        }
        public string SecOptions
        {
            get;
             private set;
        }
        public string SecRegistration
        {
            get;
             private set;
        }

        string maskHFile = "^\\s*#define\\s*([\\w]*)\\s*(\\d*)\\s*(/\\*\\s*(.*?)\\s*\\*/)?";
        string maskGUIFile = "^\\s*(\\w+)\\s*\"(.*?)\"\\s*(\\w*)";
        string maskSOFile = "^\\s*public\\s*const\\s*int\\s*(\\w*)\\s*=\\s*(\\d*)\\s*;\\s*(/\\*\\s*(.*?)\\s*\\*/)?";
        string maskSRFile = "^\\s*(GcmTools\\.)?SecItem\\.SetItemOpt\\(([^,]*),([^,]*),([^,]*),([^,]*,)?\\s*SecOptions\\.(\\w*)\\s*\\);";
        
        public Collection<HItem> HItemCollection = new Collection<HItem>();
        public Collection<GuiItem> GuiItemCollection = new Collection<GuiItem>();
        public Collection<SecOptionItem> SecOptionCollection = new Collection<SecOptionItem>();
        public Collection<SecRegItem> SecRegCollection = new Collection<SecRegItem>();

        public event EventHandler InfoRetrived;

        public void GetInfo()
        {
            HItemCollection.Clear();
            GuiItemCollection.Clear();
            SecOptionCollection.Clear();
            SecRegCollection.Clear();

            Task t1 = Task.Factory.StartNew(new Action(GetHFileInfo));
            Task t2 = Task.Factory.StartNew(new Action(GetGuiInfo));
            Task t3 = Task.Factory.StartNew(new Action(GetSecOptionInfo));
            Task t4 = Task.Factory.StartNew(new Action(GetRegisteredOptions));
            Task.WaitAll(t1, t2, t3, t4);
            if (InfoRetrived != null)
                InfoRetrived(this, EventArgs.Empty);
        }

        private void GetRegisteredOptions()
        {
            string strTmp = SecRegistration.ReadFile();
            var list = strTmp.GetMatches(maskSRFile, new int[] {  2, 3, 4, 5, 6 }, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            foreach (var item in list)
            {
                SecRegItem i = new SecRegItem();
                i.Param1 = item[2];
                i.Param2 = item[3];
                i.Param3 = item[4];
                i.Param4 = item[5];
                i.Kod = item[6];
                i.System = System;
                SecRegCollection.Add(i);
            }
        }
        private void GetSecOptionInfo()
        {
            string strTmp = SecOptions.ReadFile();
            var list = strTmp.GetMatches(maskSOFile, new int[] { 1, 2, 4 }, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            foreach (var item in list)
            {
                SecOptionItem i = new SecOptionItem();
                i.Nazwa = item[4];
                i.Kod = item[1];
                i.Numer = item[2];
                i.System = System;
                SecOptionCollection.Add(i);
            }
        }
        private void GetGuiInfo()
        {
            string strTmp = GUIfile.ReadFile();
            var list = strTmp.GetMatches(maskGUIFile, new int[] { 1, 2, 3 }, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            foreach (var item in list)
            {
                GuiItem i = new GuiItem();
                i.Parent = item[1];
                i.Nazwa = item[2].Trim().TrimStart('\"').TrimEnd('\"');
                i.Kod = item[3];
                i.System = System;
                GuiItemCollection.Add(i);
            }
        }
        private void GetHFileInfo()
        {
            string strTmp = Hfile.ReadFile();
            var list = strTmp.GetMatches(maskHFile, new int[] { 1, 2, 4 }, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            foreach (var item in list)
            {
                HItem i = new HItem();
                i.Nazwa = item[4].Trim().TrimStart('\"').TrimEnd('\"');
                i.Kod = item[1];
                i.Numer = item[2];
                i.System = System;
                HItemCollection.Add(i);
            }
        }
    }

    public class MismatchKodItem : SystemFile
    {
        public string Kod { get; set; }
        public string HItemNumer { get; set; }
        public string HItemNazwa { get; set; }
        public string SecOptionNumer { get; set; }
        public string SecOptionNazwa { get; set; }
    }

    public class MismatchNumerItem : SystemFile
    {
        public string Numer { get; set; }
        public string HItemKod { get; set; }
        public string HItemNazwa { get; set; }
        public string SecOptionKod { get; set; }
        public string SecOptionNazwa { get; set; }
    }

    public class HItem : SystemFile
    {
        public string Numer { get; set; }
        public string Kod { get; set; }
        public string Nazwa { get; set; }
    }

    public class SecOptionItem : SystemFile
    {
        public string Numer { get; set; }
        public string Kod { get; set; }
        public string Nazwa { get; set; }
    }
    public class SecRegItem : SystemFile
    {
        public string Kod { get; set; }
        public string Param1 { get; set; }
        public string Param2 { get; set; }
        public string Param3 { get; set; }
        public string Param4 { get; set; }
        public string Params { get { return Param1.Trim() + ", " + Param2.Trim() + ", " + Param3.Trim() + (Param4.IsNotNull() ? (", " + Param4.Trim()) : ""); } }
    }
    public class GuiItem : SystemFile
    {
        public string Parent { get; set; }
        public string Kod { get; set; }
        public string Nazwa { get; set; }
        public override string ToString()
        {
            return Kod;
        }
    }
}
